
	** Uganda
	** Clean wave 4
		
	** Urban status
	
		use "$dir/rawdata/LSMS Uganda/2013/GSEC1.dta", clear
		gen w4_urban=urban==1
		
		keep HHID w4_*
		ren HHID hhid
		
		tempfile urban
		save `urban', replace
		
	** Roster
		use "$dir/rawdata/LSMS Uganda/2013/GSEC2.dta", clear
		
		gen w4_female=h2q3==2 if !missing(h2q3)
		gen w4_age=h2q8
		gen w4_married=(h2q10==1 | h2q10==2) if !missing(h2q10)
		
		gen w4_inhh=h2q7<=4
		
		bys HHID: egen w4_hh_size=total(w4_inhh)
		
		ren HHID hhid
		ren PID indiv
		
		keep hhid indiv w4_*
		tempfile roster
		save `roster', replace
		
	** Illness or injury
	
		use "$dir/rawdata/LSMS Uganda/2013/GSEC5.dta", clear
	
		gen w4_illinj=h5q4==1 if !missing(h5q4)
		gen w4_illinjstopactivities=h5q6>0 if !missing(h5q6)
		replace w4_illinjstopactivities=0 if w4_illinj==0
		
		ren HHID hhid
		ren PID indiv 
		
		keep hhid indiv w4_*		
		tempfile illinj
		save `illinj', replace
		
	** Employment 
		
		use "$dir/rawdata/LSMS Uganda/2013/GSEC8_1.dta", clear
		
		gen w4_work_outsideHH=h8q4==1 if !missing(h8q4)
		
		gen w4_work_bizHH=(h8q6==1 | h8q8==1) if (!missing(h8q6) | !missing(h8q8))
		
		gen w4_work_agHH=(h8q12==1) if !missing(h8q12)
		
		egen w4_worked_last7days=rowmax(w4_work_outsideHH w4_work_agHH w4_work_bizHH)
		
		egen w4_work_hrs=rowtotal(h8q36a h8q36b h8q36c h8q36d h8q36e h8q36f h8q36g h8q43), mi // inludes working on a household business, agriculture, etc.
		
		ren HHID hhid
		ren PID indiv
		keep hhid indiv w4_*
		
		tempfile employment
		save `employment', replace

	** Disabilities
	
		*n/a	
			
	** Merge and save
	
		use `roster', clear
		merge 1:1 hhid indiv using `illinj', gen(merge_illinj)
		merge 1:1 hhid indiv using `employment', gen(merge_employment)
		merge m:1 hhid using `urban', gen(merge_urban)
		
		save "$dir/data/uga_w4_individual.dta", replace
